package org.oschina.api.manage.illegalchar.dao;

import java.util.List;

import org.oschina.api.BaseDAO;
import org.oschina.api.manage.illegalchar.model.IllegalChar;
import org.oschina.api.manage.illegalchar.vo.IllegalCharVo;
import org.springframework.stereotype.Repository;

@Repository
public class IllegalCharDAO extends BaseDAO {

	private final String findVo[]={"id","name","`replace`","`source`","create_time"};
	
	/**
	 * 返回
	 * @return
	 */
	public List<IllegalCharVo> findVo()
	{
		return getQueryHelper().query_cache(findVo, null, null, null, IllegalCharVo.class, -1, -1);
	}
	
	/**
	 * 创建
	 * @param illegalChar
	 * @return
	 */
	public IllegalChar create(IllegalChar illegalChar)
	{
		getQueryHelper().insert_cache(new String[]{"id","name","`replace`","`source`","create_time"}, 
				new Object[]{illegalChar.getId(),illegalChar.getName(),illegalChar.getReplace(),illegalChar.getSource(),illegalChar.getCreate_time()}, IllegalCharVo.class);
		return illegalChar;
	}
	
	/**
	 * 更新
	 * @param illegalChar
	 * @return
	 */
	public int update(IllegalChar illegalChar)
	{
		return (int) getQueryHelper().update_cache(new String[]{"name=?","`replace`=?","`source`=?"}, new String[]{"id=?"}, 
				new Object[]{illegalChar.getName(),illegalChar.getReplace(),illegalChar.getSource(),illegalChar.getId()}, IllegalCharVo.class);
	}
	
	/**
	 * 删除
	 * @return
	 */
	public int remove(int id)
	{
		return (int) getQueryHelper().delete_cache(new String[]{"id=?"}, new Object[]{id}, IllegalCharVo.class);
	}
}